#include "WindowHandler.h"
#include <GL/glew.h>
#include <GL/glfw.h>

WindowHandler::WindowHandler(){
}

WindowHandler::~WindowHandler(){
}
const void WindowHandler::initialize(){
	glfwInit();
	glewInit();
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 4);
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1);
	glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Only use OpenGLs core profile. This means that depreciated features cannot be used.
}

const void WindowHandler::cleanup(){
	glfwTerminate();
}

const void WindowHandler::openWindow(int width, int height, std::string title, int xPos, int yPos){
	glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW);
	setWindowSize(width, height);
	setWindowTitle(title);
	setWindowPos(xPos, yPos);
}

const void WindowHandler::closeWindow(){
	glfwCloseWindow();
}


const void WindowHandler::setWindowSize(int width, int height){
	glfwSetWindowSize(width, height);
	glViewport(0, 0, (GLsizei)width, (GLsizei)height);
}

const void WindowHandler::setWindowTitle(std::string title){
	glfwSetWindowTitle(title.c_str());
}

const void WindowHandler::setWindowPos(int xPos, int yPos){
	glfwSetWindowPos(xPos, yPos);
}

const int WindowHandler::isOpened(){
	return glfwGetWindowParam(GLFW_OPENED);
}

const void WindowHandler::swapBuffers(){
	glfwSwapBuffers();
}